const Router = require('koa-router')
const router = new Router({ prefix: "/goods" })
const { auth, hadAdminPermission } = require('../middleware/auth.middleware')
const { upload, create, update, remove1, renew, findAllgoods } = require('../controller/good.controller')
const { validator } = require('../middleware/goods.middleware')

// 物品上传路由
router.post("/upload", auth, hadAdminPermission, upload)
// 发布商品上传接口
//router.post('/',auth,hadAdminPermission,validator,create)
router.post("/", validator, create)
// 修改商品信息
router.put('/:id', validator, update)
// 商品下架（软删除）
router.post('/:id/off', remove1)
// 商品上架（软恢复）
router.post('/:id/on', renew)
// 商品列表
router.get('/', findAllgoods)
module.exports = router
